#include "wiiuse/wpad.h"

#include "input.h"
	
namespace Input{
	
		
	bool LeftHeld(){return WPAD_ButtonsHeld(WPAD_CHAN_0) & WPAD_BUTTON_LEFT;}
	bool RightHeld(){return WPAD_ButtonsHeld(WPAD_CHAN_0) & WPAD_BUTTON_RIGHT;}
	bool UpHeld(){return WPAD_ButtonsHeld(WPAD_CHAN_0) & WPAD_BUTTON_UP;}
	bool DownHeld(){return WPAD_ButtonsHeld(WPAD_CHAN_0) & WPAD_BUTTON_DOWN;}
		
	bool LeftDown(){return WPAD_ButtonsDown(WPAD_CHAN_0) & WPAD_BUTTON_LEFT;}
	bool RightDown(){return WPAD_ButtonsDown(WPAD_CHAN_0) & WPAD_BUTTON_RIGHT;}
	bool UpDown(){return WPAD_ButtonsDown(WPAD_CHAN_0) & WPAD_BUTTON_UP;}
	bool DownDown(){return WPAD_ButtonsDown(WPAD_CHAN_0) & WPAD_BUTTON_DOWN;}
	
	bool MovingHeld()
	{
		return WPAD_ButtonsHeld(WPAD_CHAN_0) & (WPAD_BUTTON_UP
			|WPAD_BUTTON_DOWN|WPAD_BUTTON_LEFT|WPAD_BUTTON_RIGHT);
	}
	
	bool MovingDown()
	{
		return WPAD_ButtonsDown(WPAD_CHAN_0) & (WPAD_BUTTON_UP
			|WPAD_BUTTON_DOWN|WPAD_BUTTON_LEFT|WPAD_BUTTON_RIGHT);
	}





	// The following can be optimized more once the control scheme is finalized.
	s32 TriHorHeld()  //  -1 = Left, 0 = neither, 1 = Right	
	{
		return RightHeld() - LeftHeld();
	}
	s32 TriVerHeld()  //  -1 = Up, 0 = neither, 1 = Down  
	{
		return DownHeld() - UpHeld();
	}
	
	s32 TriHorDown()
	{
		return RightDown() - LeftHeld();
	}
	s32 TriVerDown()
	{
		return DownDown() - UpDown();
	}
}